<template>
	<view class="news-detail">
		<view class="title">{{detail.title}}</view>
		<view class="info">
			<text>发表时间：{{detail.add_time | dateFormat}}</text>
			<text>浏览：{{detail.click}}</text>
		</view>
		<view class="content" v-html="detail.content"></view>
	</view>
</template>

<script>
	import {getNewsDetail} from '../../../api/news/detail.js'
	export default {
		data() {
			return {
				detail: {}
			}
		},
		methods: {
			/**
			 * 获取资讯详情
			 * @param {Object} id 资讯id
			 */
			getNewsDetail(id) {
				getNewsDetail(id).then(res => {
					this.detail = res.data.message[0];
					console.log(res)
				})
			}
		},
		onLoad(options) {
			this.getNewsDetail(options.id);
		},
		filters: {
			dateFormat(date) {
				return date.substring(0, date.length - 5).replace("T", " ");
			}
		}
	}
</script>

<style scoped lang="scss">
 @import '~@/static/css/news/detail.scss';
</style>
